import 'package:flustars/flustars.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBEngineer/YBBaseRouter/YBApplication.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBEngineer/YBBaseRouter/YBNavigator.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBEngineer/YBProjectPopPage/YBZuZhiGuanLiQuanXianPage.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBEngineer/YBWeChatPopPage/YBCameraSelectPopPage.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/YBColor/YBColor.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/YBImageStyle/YBImageStyle.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/YBTextStyle/YBTextStyle.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/yb_chinese_text/yb_chinese_text.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBJsonToModel/YBFindModel/YBFindModel.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBModule/YBFindModule/YBFindProvider/YBFindProvider.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBModule/YBFindModule/YBFindSubPage/YBFindHeaderSubPage.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBModule/YBFindModule/YBFindSubPage/YBNewFindSubPage.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBUtils/YBBaseUtils/YBisLoginUtils.dart';


class YBNewFindMainPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
       child: Scaffold(
         appBar: AppBar(
            elevation: 0,
            title: Text(YBChineseText.findQuanCengTitle,style: YBTextStyle.TextStyle30313320Medium),
            actions: [
              InkWell(
                child: Container(
                  child: Image.asset(YBImageStyle.getImagePath('faxian_xierushuju')),
                ),
                onTap: () async {
                  if (YBisLoginUtils.isLogin() == true){
                    if(YBisLoginUtils.isVip() == true){
                      YBCameraSelectPopPage.getQuanCengInfoSelectPop(context);
                    }else{
                      YBZuZhiGuanLiQuanXianPage.showZuZhiGuanLiQuanXian(context);
                    }
                  }else{
                    YBApplication.router.navigateTo(context, '/loginIn');
                  }
                },
              ),
            ],
         ),
         body: ChangeNotifierProvider(
             create: (context) => YBFindMainProvider()..getFindDataList(1, "faxian"),
             child: Consumer<YBFindMainProvider>(
                 builder: (context,findDataList,child){
                    return SmartRefresher(
                      controller:findDataList.easyRefreshController,
                      enablePullDown: true,
                      enablePullUp: true,
                      onRefresh: (){
                        findDataList.refreshData("faxian");
                      },
                      onLoading: () {
                        findDataList.loadData("faxian");
                      },
                      header: WaterDropHeader(),
                      child: CustomScrollView(
                        slivers: [
                          SliverToBoxAdapter(
                            child: Container(
                              color: YBColor.white,
                              child: Column(
                                mainAxisAlignment: MainAxisAlignment.start,
                                crossAxisAlignment: CrossAxisAlignment.stretch,
                                children: [
                                  Container(
                                    child: Padding(
                                      padding: EdgeInsets.only(left: ScreenUtil.getInstance().getAdapterSize(20.0),top: ScreenUtil.getInstance().getAdapterSize(12.0)),
                                      child: Text(YBChineseText.findFaXianPingPaiTitle,style:TextStyle(
                                          color: YBColor.color181818,
                                          fontSize:YBTextStyle.adapterSize16,
                                          fontWeight: FontWeight.w600
                                      )),
                                    ),
                                  ),
                                ],
                              ),
                            ),
                          ),
                          SliverToBoxAdapter(
                            child: Container(
                              height: YBTextStyle.adapterSize10,
                              color: YBColor.white,
                            ),
                          ),
                          SliverToBoxAdapter(
                            child: Container(
                              color: YBColor.white,
                              height: YBTextStyle.adapterSize70,
                              child: Padding(
                                padding: EdgeInsets.only(left:YBTextStyle.adapterSize20,right: YBTextStyle.adapterSize20),
                                child: Row(
                                  mainAxisAlignment: MainAxisAlignment.spaceAround,
                                  crossAxisAlignment: CrossAxisAlignment.center,
                                  children: [
                                    //
                                    Container(
                                      child: InkWell(
                                        child: YBFindHeaderSubPage(titleStr: YBChineseText.findYiJiWangTitle,imageStr: "yiji",),
                                        onTap: () async {
                                          YBNavigatorUtil.jump(context, '/findQuanCengPage/findQuanCengDetailWebViewPage?webUrl=${Uri.encodeComponent("http://m.yiji365.com?from=app")}');
                                        },
                                      ),
                                    ),
                                    Container(
                                      child: InkWell(
                                        child: YBFindHeaderSubPage(titleStr: YBChineseText.findJinRiLvSiTitle,imageStr: "jinri_lvsi",),
                                        onTap: () async {
                                          YBNavigatorUtil.jump(context, '/findQuanCengPage/findQuanCengDetailWebViewPage?webUrl=${Uri.encodeComponent("http://m.jinrilvsi.com?from=app")}');
                                        },
                                      ),
                                    ),
                                    Container(
                                      child: InkWell(
                                        child: Container(
                                          child: Column(
                                            mainAxisAlignment: MainAxisAlignment.center,
                                            crossAxisAlignment: CrossAxisAlignment.center,
                                            children: [
                                              Container(
                                                width: YBTextStyle.adapterSize40,
                                                height: YBTextStyle.adapterSize40,
                                                child: Image.asset(YBImageStyle.getImagePath("faxian_ebanshi")),
                                              ),
                                              Container(
                                                height: YBTextStyle.adapterSize8,
                                              ),
                                              Container(
                                                child: Text(
                                                  YBChineseText.findEBanShiTitle,
                                                  style: TextStyle(
                                                    color: YBColor.color606266,
                                                    fontWeight: FontWeight.w400,
                                                    fontSize: YBTextStyle.adapterSize11,
                                                  ),
                                                ),
                                              ),
                                            ],
                                          ),
                                        ),
                                        onTap: () async {
                                          YBApplication.router.navigateTo(context, '/findQuanCengPage/findQuanCengDetailWebViewPage?webUrl=${Uri.encodeComponent("http://m.laizone.cn?from=app")}');
                                        },
                                      ),
                                    ),
                                    Container(
                                      child: InkWell(
                                        child: YBFindHeaderSubPage(titleStr: YBChineseText.findBenLaiYouShuTitle,imageStr: "youshu",),
                                        onTap: () async {
                                          YBApplication.router.navigateTo(context, '/findQuanCengPage/findQuanCengDetailWebViewPage?webUrl=${Uri.encodeComponent("http://m.laizone.com?from=app")}');
                                        },
                                      ),
                                    ),
                                    Container(
                                      child: InkWell(
                                        child:Container(
                                          child: Column(
                                            mainAxisAlignment: MainAxisAlignment.center,
                                            crossAxisAlignment: CrossAxisAlignment.center,
                                            children: [
                                              Container(
                                                width: YBTextStyle.adapterSize40,
                                                height: YBTextStyle.adapterSize40,
                                                child: Image.asset(YBImageStyle.getImagePath("faxian_lvdouxinyong")),
                                              ),
                                              Container(
                                                height: YBTextStyle.adapterSize8,
                                              ),
                                              Container(
                                                child: Text(
                                                  YBChineseText.findLvDouXinYongTitle,
                                                  style: TextStyle(
                                                    color: YBColor.color606266,
                                                    fontWeight: FontWeight.w400,
                                                    fontSize: YBTextStyle.adapterSize11,
                                                  ),
                                                ),
                                              ),
                                            ],
                                          ),
                                        ),
                                        onTap: () async {
                                          YBApplication.router.navigateTo(context, '/findQuanCengPage/findQuanCengDetailWebViewPage?webUrl=${Uri.encodeComponent("http://xin.ebs321.com?from=app")}');
                                        },
                                      ),
                                    ),
                                  ],
                                ),
                              ),
                            ),
                          ),
                          SliverToBoxAdapter(
                            child: Container(
                              height: YBTextStyle.adapterSize10,
                              color: YBColor.white,
                            ),
                          ),
                          SliverToBoxAdapter(
                            child: Container(
                              height: YBTextStyle.adapterSize8,
                              color: YBColor.colorF5F5F7,
                            ),
                          ),
                          SliverList(
                            delegate: SliverChildBuilderDelegate((BuildContext context,int index){
                              YBFindModel findModel = findDataList.findModelList[index];
                              return YBNewFindSubPage(findModel: findModel,);
                            },childCount: findDataList.findModelList.length),
                          ),
                        ],
                      ),

                    );
                    // return EasyRefresh.custom(
                    //     enableControlFinishRefresh: true,
                    //     enableControlFinishLoad: true,
                    //     onRefresh: () async {
                    //       findDataList.refreshData('faxian');
                    //     },
                    //     onLoad: () async {
                    //       findDataList.loadData('faxian');
                    //     },
                    //     header: PhoenixHeader(),
                    //     footer: PhoenixFooter(),
                    //    // controller: findDataList.easyRefreshController,
                    //     slivers: [
                    //       SliverToBoxAdapter(
                    //         child: Container(
                    //            color: YBColor.white,
                    //            child: Column(
                    //              mainAxisAlignment: MainAxisAlignment.start,
                    //              crossAxisAlignment: CrossAxisAlignment.stretch,
                    //              children: [
                    //                 Container(
                    //                   child: Padding(
                    //                     padding: EdgeInsets.only(left: ScreenUtil.getInstance().getAdapterSize(20.0),top: ScreenUtil.getInstance().getAdapterSize(12.0)),
                    //                     child: Text(YBChineseText.findFaXianPingPaiTitle,style:TextStyle(
                    //                       color: YBColor.color181818,
                    //                       fontSize:YBTextStyle.adapterSize16,
                    //                       fontWeight: FontWeight.w600
                    //                     )),
                    //                   ),
                    //                 ),
                    //              ],
                    //            ),
                    //         ),
                    //       ),
                    //       SliverToBoxAdapter(
                    //         child: Container(
                    //           height: YBTextStyle.adapterSize10,
                    //           color: YBColor.white,
                    //         ),
                    //       ),
                    //       SliverToBoxAdapter(
                    //         child: Container(
                    //           color: YBColor.white,
                    //           height: YBTextStyle.adapterSize70,
                    //           child: Padding(
                    //             padding: EdgeInsets.only(left:YBTextStyle.adapterSize20,right: YBTextStyle.adapterSize20),
                    //             child: Row(
                    //               mainAxisAlignment: MainAxisAlignment.spaceAround,
                    //               crossAxisAlignment: CrossAxisAlignment.center,
                    //               children: [
                    //                 //
                    //                 Container(
                    //                   child: InkWell(
                    //                     child: YBFindHeaderSubPage(titleStr: YBChineseText.findYiJiWangTitle,imageStr: "yiji",),
                    //                     onTap: () async {
                    //                       YBNavigatorUtil.jump(context, '/findQuanCengPage/findQuanCengDetailWebViewPage?webUrl=${Uri.encodeComponent("http://m.yiji365.com")}');
                    //                     },
                    //                   ),
                    //                 ),
                    //                 Container(
                    //                   child: InkWell(
                    //                     child: YBFindHeaderSubPage(titleStr: YBChineseText.findJinRiLvSiTitle,imageStr: "jinri_lvsi",),
                    //                     onTap: () async {
                    //                       YBNavigatorUtil.jump(context, '/findQuanCengPage/findQuanCengDetailWebViewPage?webUrl=${Uri.encodeComponent("http://m.jinrilvsi.com")}');
                    //                     },
                    //                   ),
                    //                 ),
                    //                 Container(
                    //                   child: InkWell(
                    //                     child: Container(
                    //                       child: Column(
                    //                         mainAxisAlignment: MainAxisAlignment.center,
                    //                         crossAxisAlignment: CrossAxisAlignment.center,
                    //                         children: [
                    //                           Container(
                    //                             width: YBTextStyle.adapterSize40,
                    //                             height: YBTextStyle.adapterSize40,
                    //                             child: Image.asset(YBImageStyle.getImagePath("faxian_ebanshi")),
                    //                           ),
                    //                           Container(
                    //                             height: YBTextStyle.adapterSize8,
                    //                           ),
                    //                           Container(
                    //                             child: Text(
                    //                               YBChineseText.findEBanShiTitle,
                    //                               style: TextStyle(
                    //                                 color: YBColor.color606266,
                    //                                 fontWeight: FontWeight.w400,
                    //                                 fontSize: YBTextStyle.adapterSize11,
                    //                               ),
                    //                             ),
                    //                           ),
                    //                         ],
                    //                       ),
                    //                     ),
                    //                     onTap: () async {
                    //                       YBApplication.router.navigateTo(context, '/findQuanCengPage/findQuanCengDetailWebViewPage?webUrl=${Uri.encodeComponent("http://m.laizone.cn")}');
                    //                     },
                    //                   ),
                    //                 ),
                    //                 Container(
                    //                   child: InkWell(
                    //                     child: YBFindHeaderSubPage(titleStr: YBChineseText.findBenLaiYouShuTitle,imageStr: "youshu",),
                    //                     onTap: () async {
                    //                       YBApplication.router.navigateTo(context, '/findQuanCengPage/findQuanCengDetailWebViewPage?webUrl=${Uri.encodeComponent("http://m.laizone.com")}');
                    //                     },
                    //                   ),
                    //                 ),
                    //                 Container(
                    //                   child: InkWell(
                    //                     child:Container(
                    //                       child: Column(
                    //                         mainAxisAlignment: MainAxisAlignment.center,
                    //                         crossAxisAlignment: CrossAxisAlignment.center,
                    //                         children: [
                    //                           Container(
                    //                             width: YBTextStyle.adapterSize40,
                    //                             height: YBTextStyle.adapterSize40,
                    //                             child: Image.asset(YBImageStyle.getImagePath("faxian_lvdouxinyong")),
                    //                           ),
                    //                           Container(
                    //                             height: YBTextStyle.adapterSize8,
                    //                           ),
                    //                           Container(
                    //                             child: Text(
                    //                               YBChineseText.findLvDouXinYongTitle,
                    //                               style: TextStyle(
                    //                                 color: YBColor.color606266,
                    //                                 fontWeight: FontWeight.w400,
                    //                                 fontSize: YBTextStyle.adapterSize11,
                    //                               ),
                    //                             ),
                    //                           ),
                    //                         ],
                    //                       ),
                    //                     ),
                    //                     onTap: () async {
                    //                       YBApplication.router.navigateTo(context, '/findQuanCengPage/findQuanCengDetailWebViewPage?webUrl=${Uri.encodeComponent("http://xin.ebs321.com")}');
                    //                     },
                    //                   ),
                    //                 ),
                    //               ],
                    //             ),
                    //           ),
                    //         ),
                    //       ),
                    //       SliverToBoxAdapter(
                    //         child: Container(
                    //           height: YBTextStyle.adapterSize10,
                    //           color: YBColor.white,
                    //         ),
                    //       ),
                    //       SliverToBoxAdapter(
                    //         child: Container(
                    //            height: YBTextStyle.adapterSize8,
                    //            color: YBColor.colorF5F5F7,
                    //         ),
                    //       ),
                    //       SliverList(
                    //         delegate: SliverChildBuilderDelegate((BuildContext context,int index){
                    //           YBFindModel findModel = findDataList.findModelList[index];
                    //           return YBNewFindSubPage(findModel: findModel,);
                    //         },childCount: findDataList.findModelList.length),
                    //       ),
                    //    ]
                    // );
                 }
             ),
         ),
       ),
    );
  }
}
